home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SoundMaker 2003 (Professional Edition)
/
SoundMaker 2003 - Professional Edition.iso
/
midi tool
/
midioxse.exe
/
DATA.1
/
VBSPoll.vbs
< prev
next >
Wrap
Text File
|
1999-11-26
|
4KB
|
134 lines
' MIDIOX Test - Polling Example
' Copyright (c) 2000 by Jamie O'Connell
'
' This script is an example of using VBScript with MIDI-OX
option explicit
dim mox
dim str, strWrk, strSysEx
dim n, ii, nInst
dim bGo
dim chan, stat, dat1, dat2
dim msg, msgstr
dim A
' Wsh version
Str = Wscript.Name & " ver. " & Wscript.Version
MsgBox str
' Create object
Set mox = WScript.CreateObject("MoxKart.MoxWire.1")
str = "MIDI-OX"
n = mox.NumberInstances
If n > 0 Then
str = str & ":" & CStr( n )
Else
MsgBox "No Instances"
End If
str = str & " "
str = str & mox.GetAppVersion
MsgBox str
If n > 0 then
nInst = 1
If n > 1 then
nInst = InputBox( "Attach to which instance? (1 to " & n & ")", "Attach", "1" )
End If
If mox.AttachInstance( nInst ) = 1 Then
MsgBox "Attached Instance: " & nInst
Else
MsgBox "Could not Attach Instance: " & nInst
End If
ElseIf vbYes = MsgBox( "Launch MIDI-OX?", vbYesNo + vbQuestion, "Launch" ) Then
If mox.LaunchInstance = 1 Then
nInst = 1
If mox.AttachInstance( nInst ) = 1 Then
MsgBox "Launched and Attached Instance: " & nInst
Else
MsgBox "Launched but could not Attach Instance: " & nInst
End If
Else
MsgBox "Launch MIDI-OX Failed"
End If
n = mox.NumberInstances
End if
' *** Try out our MIDI Input loop
mox.FireMidiInput = 0
str = "Enter MIDI Input Loop?" & vbCrLf & "(Exit Script from MIDI-OX)"
If mox.IsAttached = 1 And vbYes = MsgBox( str, vbYesNo + vbQuestion, "MIDI Notes" ) Then
If vbYes = MsgBox( "Divert MIDI Input?", vbYesNo + vbQuestion, "MIDI Notes" ) Then
mox.DivertMidiInput = 1
Else
mox.DivertMidiInput = 0
End If
Do While mox.ShouldExitScript = 0
' First way of getting input: try raw Input
msg = mox.GetMidiInputRaw()
If msg <> 0 Then
stat = msg And &h000000F0
chan = msg And &h0000000F
If mox.DivertMidiInput = 0 And (stat = &h90 Or stat = &h80) Then
chan = chan + 1
If chan > 15 Then
chan = 0
End If
End If
If (stat = &hF0) Then ' SysEx, must ask for SysEx string message
strSysEx = mox.GetSysExInput()
mox.SendSysExString strSysEx
Else
msg = msg \ 256 ' pull off stat
dat1 = msg And &h0000007F
msg = msg \ 256
dat2 = msg And &h0000007F
mox.OutputMidiMsg stat + chan, dat1, dat2
End If
End If
' Second way: Now try the string format
msgStr = mox.GetMidiInput()
If msgStr <> "" Then
A = Split( msgStr, ",", -1, vbTextCompare )
stat = Int(A(1))
chan = Int(A(2))
If mox.DivertMidiInput = 0 And (stat = &h90 Or stat = &h80) Then
chan = chan + 1
If chan > 15 Then
chan = 0
End If
End If
If (stat = &hF0) Then ' SysEx, must ask for SysEx string message
strSysEx = mox.GetSysExInput()
mox.SendSysExString strSysEx
Else
dat1 = Int(A(3))
dat2 = Int(A(4))
mox.OutputMidiMsg stat + chan, dat1, dat2
End If
End If
Loop
mox.DivertMidiInput = 0
End If
MsgBox "End Demo"
Set str = nothing
Set strWrk = nothing
Set mox = nothing
Set strSysEx = nothing
' Exit Point
'------------------------------------------